﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GameTank3D
{
    public class IntroScene : GameScene
    {        
        SpriteBatch spriteBatch;
        Menu menu;
        Texture2D menubackground;
        Texture2D[] itemtextureNormal;
        Texture2D[] itemtextureSelect;
        Texture2D gamebackgrond;
        Texture2D gameLogo;
        int n;

        public IntroScene(Game game)
        {
            this.Game = game;
        }

        public override void LoadContent(ContentManager Content)
        {
            spriteBatch = (SpriteBatch) Game.Services.GetService(
                                            typeof (SpriteBatch));

            menubackground = Content.Load<Texture2D>("MenuBackGround");
            n = 5;
            itemtextureNormal = new Texture2D[n];
            itemtextureNormal[0] = Content.Load<Texture2D>("NewGame");
            itemtextureNormal[1] = Content.Load<Texture2D>("Load");
            itemtextureNormal[2] = Content.Load<Texture2D>("Option");
            itemtextureNormal[3] = Content.Load<Texture2D>("About");
            itemtextureNormal[4] = Content.Load<Texture2D>("Exit");
            itemtextureSelect = new Texture2D[n];
            itemtextureSelect[0] = Content.Load<Texture2D>("NewGameSel");
            itemtextureSelect[1] = Content.Load<Texture2D>("LoadSel");
            itemtextureSelect[2] = Content.Load<Texture2D>("OptionSel");
            itemtextureSelect[3] = Content.Load<Texture2D>("AboutSel");
            itemtextureSelect[4] = Content.Load<Texture2D>("ExitSel");
            menu = new Menu(this.Game, menubackground, itemtextureNormal, itemtextureSelect);
            menu.Initialize();
            gamebackgrond = Content.Load<Texture2D>("BackGround");
            gameLogo = Content.Load<Texture2D>("TankPro");
        }

        public override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Game.Exit();
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Game.Exit();
            // TODO: Add your update logic here
            menu.Update(gameTime);
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {         
            spriteBatch.Begin();
            spriteBatch.Draw(gamebackgrond, new Vector2(0, 0), Color.White);
            spriteBatch.Draw(gameLogo, new Vector2((Game.Window.ClientBounds.Width - gameLogo.Width) / 2, (Game.Window.ClientBounds.Height - gameLogo.Height) / 20), Color.White);
            menu.Draw(gameTime);
            base.Draw(gameTime);
            spriteBatch.End();
        }
    }
}
